﻿using UnityEngine;
using Unity.Entities;

public class HealthAuthoring : MonoBehaviour
{
    public float healthAmount;
    public float healthAmountMax;
    public bool onHealthChanged;
    public class Baker : Baker<HealthAuthoring>
    {
        public override void Bake(HealthAuthoring authoring)
        {
            Entity entity = GetEntity(TransformUsageFlags.Dynamic);
            AddComponent(entity, new Health
            {
                healthAmount = authoring.healthAmount,
                healthAmountMax = authoring.healthAmountMax,
                onHealthChanged = authoring.onHealthChanged
            });
        }
    }
}

public struct Health : IComponentData
{
    public float healthAmount;
    public float healthAmountMax;
    public bool onHealthChanged;
    /// <summary>
    /// 实体死亡调用
    /// </summary>
    public bool onDead;
}
